﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class OccupationBL
	{

		#region ***** Init Methods ***** 
		OccupationDA objOccupationDA;
		public OccupationBL()
		{
			objOccupationDA = new OccupationDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get Occupation by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>Occupation</returns>
		public Occupation GetByID(int id)
		{
			return objOccupationDA.GetByID(id);
		}

		/// <summary>
		/// Get all of Occupation
		/// </summary>
		/// <returns>List<<Occupation>></returns>
		public List<Occupation> GetList()
		{
			string cacheName = "lstOccupation";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objOccupationDA.GetList(), "Occupation");
			}
			return (List<Occupation>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of Occupation
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsOccupation";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objOccupationDA.GetDataSet(), "Occupation");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of Occupation paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<Occupation>></returns>
		public List<Occupation> GetListPaged(int recperpage, int pageindex)
		{
			return objOccupationDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of Occupation paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objOccupationDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new Occupation within Occupation database table
		/// </summary>
		/// <param name="obj_occupation">Occupation</param>
		/// <returns>key of table</returns>
		public int Add(Occupation obj_occupation)
		{
			ServerCache.Remove("Occupation", true);
			return objOccupationDA.Add(obj_occupation);
		}

		/// <summary>
		/// updates the specified Occupation
		/// </summary>
		/// <param name="obj_occupation">Occupation</param>
		/// <returns></returns>
		public void Update(Occupation obj_occupation)
		{
			ServerCache.Remove("Occupation", true);
			objOccupationDA.Update(obj_occupation);
		}

		/// <summary>
		/// Delete the specified Occupation
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("Occupation", true);
			objOccupationDA.Delete(id);
		}
		#endregion
	}
}
